/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.kaetec.dao;

import br.com.kaetec.entities.Cliente;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Sergio Artero
 */
public class ClienteTableModel extends AbstractTableModel {

    private List<Cliente> clientes;
    private List<String> colunas;
    
    public ClienteTableModel( List<Cliente> clientes ){
        this.clientes = clientes;
        colunas = Arrays.asList("Id", "Nome", "Rg", "Cpf");
    }
    
    @Override
    public String getColumnName( int column) {
        return colunas.get(column);
    }
    
    @Override
    public int getRowCount() {
        return clientes.size();
    }

    @Override
    public int getColumnCount() {
        return colunas.size();
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {

        Cliente cliente = clientes.get(rowIndex);
        
        switch (columnIndex){
            
            case 0: return cliente.getId();
            case 1: return cliente.getNome();
            case 2: return cliente.getRg();
            case 3: return cliente.getCpf();
                
        }
        
        return null;
    }

    public List<Cliente> getClientes() {
        return clientes;
    }

    public void setClientes(List<Cliente> clientes) {
        this.clientes = clientes;
    }
    
}